package com.gitee.zycra.future.job.client.api;

import com.gitee.zycra.future.job.client.executor.SyncStatusExecutor;

/**
 * @author zycra
 */
public abstract class JobHandler {

    private Long runningId;

    public void setRunningId(Long runningId) {
        this.runningId = runningId;
    }

    /**
     * 执行入口
     *
     * @param param 执行参数
     */
    public abstract void run(String param);

    /**
     * 更新执行进度
     *
     * @param ratio
     */
    protected final void updateRatio(int ratio) {
        SyncStatusExecutor.updateRunning(this.runningId, Math.max(1, ratio));
    }
}
